<?php


/**
 * Notes:
 * PROJECT_NAME : ERP v1.8 重构erp
 * User: 夏鱼儿<397072174@qq.com>
 * Date: 2024/3/14
 * Time: 16:37
 */

namespace app\api\model;

use think\Model;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;

/**
 * @property  int $id
 * @property  string $no
 */
class Order extends ApiBaseModel
{

    public static function onBeforeInsert(Order $model)
    {
        $model->no = "HCYT-" . date("YmdHis") . rand(10000, 99999);
    }

    public function orderDetail(): HasMany
    {
        return $this->hasMany(OrderDetail::class);
    }

    public function goodsRule(): BelongsTo
    {
        return $this->belongsTo(GoodsRule::class);
    }

}